<!DOCTYPE html>
<html>
<head>

<title>违规违章数据录入</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="css/bootstrap.min.css"></link>
<link rel="stylesheet" href="css/my.css"></link>
<link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="css/dataentry.css"></link>

<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-datetimepicker.js"></script>
<script src="js/bootstrap-datetimepicker.zh-CN.js"></script>

<script src="js/jquery.cookie.js"></script>
<script src="js/head.js"></script>
<script src="js/logincheck.js"></script>

</head>

<body>
	<div id="headnav"></div>
	<div id="loginholder"></div>

	<div class="row">
		<div class="col-md-2 side-nav">
			<div class="panel-group" id="accordion">
				<div class="panel-heading panel">
					<ul class="nav nav-pills nav-stacked">
						<li role="presentation" id="product"><a href="entry_product"
							class="pectitle">生产数据录入</a></li>
						<li role="presentation" id="peccancy" class="active"><a
							href="#" class="pectitle">违规违章数据录入</a></li>
						<li role="presentation" id="transport"><a
							href="entry_transport" class="pectitle">旅客运输数据录入</a></li>
						<li role="presentation" id="flight"><a href="entry_rota"
							class="pectitle">值班表导入</a></li>
					</ul>
				</div>
			</div>
		</div>

		<div class="col-md-9" id="myform">
			<div class="container-fluid">
				<form class="form-horizontal pecontent" role="form" id="pecform">
					<fieldset>
						<div id="legend">
							<legend class="h1">违规违章信息录入：</legend>
						</div>

						<div class="form-group">
							<label for="content" class="col-sm-2 control-label">违规违章内容：</label>
							<div class="col-sm-10 ">
								<textarea class="form-control" rows="10" id="content"></textarea>
							</div>
						</div>

						<div class="form-group">
							<label for="pecdate" class="col-sm-2 control-label">违规日期：</label>
							<div class="col-sm-10 ">
								<div class="col-sm-3" style="padding-left: 0px;">
									<input type="date" class="form-control datepicker" id="pecdate" />
								</div>
							</div>
						</div>

						<div class="form-group">
							<label for="personname" class="col-sm-2 control-label">提交者：</label>
							<div class="col-sm-10">
								<div class="col-sm-3" style="padding-left: 0px;">
									<input type="text" class="form-control" id="personname"
										placeholder="请输入姓名">
								</div>
							</div>
						</div>

						<div class="control-group">
							<div class="controls" style="float: right;">
								<button class="btn btn-primary" type="button" id="clear"
									onclick="pecclear()">清空</button>
								<button class="btn btn-primary" type="button" id="submit"
									onclick="pecsubmit()">提交</button>
							</div>
						</div>
					</fieldset>
				</form>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		function pecclear() {
			$("#pecdate").val('');
			$("#content").val('');
			$("#personname").val('');
		}

		function pecsubmit() {
			var date = $("#pecdate").val();
			var content = $("#content").val();
			var person = $("#personname").val();

			if (date == "") {
				alert('日期不能为空!');
				return false;
			}
			if (content == "") {
				alert('内容不能为空!');
				return false;
			}
			if (person == "") {
				alert('提交人不能为空!');
				return false;
			}

			$.ajax({
				type : "POST",
				url : "peccancyctrl",
				async : false,
				data : {
					"date" : date,
					"content" : content,
					"person" : person
				},
				dataType : "json",
				success : function(msg) {
					console.log('success');
					if (msg == '1') {
						alert("添加记录成功。");
						pecclear();
						//location.reload();
					} else {
						alert("添加记录失败。");
					}
				},
				error : function(data) {
					location.reload();
				}
			});
		}
	</script>
</body>